package NetEase;

import java.util.Scanner;

public class Main {
    static int res=Integer.MAX_VALUE;
    static void backtrack(int one,int two,int a,int b,int x,int y){
        if (a<=0&&b<=0){
            res=Math.min(res,one+two);
            return;
        }
        if (a>0){
            //大a
            backtrack(one+1,two,a-x,b,x,y);
        }
        if (b>0){
            backtrack(one+1,two,a,b-x,x,y);
        }
        backtrack(one,two+1,a-y,b-y,x,y);

    }
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int a=cin.nextInt();
        int b=cin.nextInt();
        int x=cin.nextInt();
        int y=cin.nextInt();
        backtrack(0,0,a,b,x,y);
        System.out.println(res);
    }

    public static void m1(){
        Scanner cin=new Scanner(System.in);
        int a=cin.nextInt();
        int b=cin.nextInt();
        int x=cin.nextInt();
        int y=cin.nextInt();
        if (y>=x){
            System.out.println(Math.max(b/y,a/y));
            return;
        }
        int[][] dp=new int[a+1][b+1];
        for (int i = 0; i < a + 1; i++) {
            for (int j = 0; j < b + 1; j++) {
                int res=Integer.MAX_VALUE;
                if (i==0&&j==0){
                    dp[i][j]=0;
                }else if ((i==0&&j<=x)||(j==0&&i<=x)||(i<=y&&j<=y)){
                    dp[i][j]=1;
                }else {
                    dp[i][j]=Math.min(dp[Math.max(i-x,0)][j],Math.max(dp[i][Math.max(j-x,0)],dp[Math.max(i-y,0)][Math.max(0,j-y)]))+1;
                }
            }
        }
        System.out.println(dp[a][b]);
    }
}

